Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: comp.lang.misc Subject: Re: Compiling and linking code from different places in the file system Date: Thu, 15 Mar 2018 08:59:25 +0100 Organization: Informatimago Lines: 164 Message-ID: References: <9K6qC.684$hq2.22@fx42.am4> Mime-Version: 1.0 Content-Type: text/plain X-Trace: individual.net xhJko/2qiI1uZfKQFt3IbwtM75bSz/PAh/4218PHALJabP8I+W Cancel-Lock: sha1:MDQyZGQ0NWY2YzQwN2UyMmQ5MDg2MjZlMGM5YmQ1MTdlNjU3OGU4MQ== sha1:Hh6bUJ8yk8vT30KD5sDE/5cCHwA= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (darwin) Xref: csiph.com comp.lang.misc:3908 bartc writes: >> make is a POSIX standard tool! >> http://pubs.opengroup.org/onlinepubs/007904975/utilities/make.html >> You can assume it is present on the system, so you can provide POSIX >> makefiles and be confident that the users will be able to compile your >> programs. > > What does that mean? > > If I type 'make' on Windows, it usually says 'file not found'. This is why MS-Windows is not a POSIX system, and why you should not use MS-Windows. >> No, but I can blame you for using MS-Windows! DUH! Don't! >> I mean the reason why you shouldn't use MS-Windows is because it's a >> poor POSIX platform. > > What's POSIX got to do with anything with anything being discussed? See above. > But clearly, it sounds like something that originated in Unix, that > might have a been good fit for how Unix works, but a poor one for > Windows. > > As it happens, I didn't choose Windows, my customers did, because it > in the early 90s is was very easy to buy Windows machines off the > shelf, completing with fully working peripherals, and much harder with > Unix machines. > > And also easier to run additional software, not just mine. Or to > anything really because everyone had them. > > But I don't remember having any build problems under Windows that > necessitated my requiring the use of makefiles or make utilities. Then why are you trying to compile and run unix or posix software on MS-Windows? Stay with MS-Windows software. >>> This is completely typical of my experience with make files. (This >>> makefile is here: https://pastebin.com/raw/Qz8QAiuS. It certainly >>> looks like a language to me.) >> >> >> Use a unix system! > > Look, the problem we're trying to solve is very simple: what subsets > of the supplied .c files need to be compiled to build the required set > of binaries. > > Because certain people insist on encoding this info in make-file > syntax, some of us have to take the drastic step of throwing away our > current OS, and all the software and know-how built up with them, just > because of of this minor point? Yes, that would be the best solution. However, notice that it is very easy to extract that information from makefiles. Even without having to parse and interpret them yourself. You can use the make -MMD option so that gcc generates a .d file with all the dependencies. Then you can just cat all the *.d files and use those dependencies. # [pjb@despina :0.0 ensemble]$ cat Makefile SOURCES=main.c ensemble.c util.c list.c ensemble_bison.c ensemble_flex.c OBJECTS=$(SOURCES:.c=.o) INCLUDES = -I. CFLAGS?=$(INCLUDES) all:ensemble ensemble_flex.c: ensemble.flex flex -o $@ $< ensemble_bison.c: ensemble.bison bison -o $@ $< ensemble_flex.o: ensemble_flex.c util.h ensemble_bison.o: ensemble_bison.c ensemble.h list.h util.h util.o:util.c util.h list.o:list.c list.h util.h ensemble.o:ensemble.c ensemble.h util.h main.o:main.c ensemble.h ensemble:$(OBJECTS) $(CC) -o $@ $(OBJECTS) clean: -rm -rf $(OBJECTS) -rm -rf ensemble_flex.c ensemble_bison.c -rm -rf ensemble test:ensemble @echo 'Empty set test:' echo '{}' | ./ensemble @echo 'Simple test:' echo '{1,2,3}' | ./ensemble @echo 'Space test:' echo ' { 1 , 2 , 3 } ' | ./ensemble @echo 'Multi-line test:' (echo '{11111,';echo '22222,';echo '33333}') | ./ensemble @echo 'Signed test:' echo '{-1000000000,-2000000,-3000,-4,-0,0,+0,+4,+3000,+2000000,+1000000000}' | ./ensemble depends: CFLAGS="$(INCLUDES) -MMD" make # [pjb@despina :0.0 ensemble]$ make clean depends rm -rf main.o ensemble.o util.o list.o ensemble_bison.o ensemble_flex.o rm -rf ensemble_flex.c ensemble_bison.c rm -rf ensemble CFLAGS="-I. -MMD" make make[1]: Entering directory '/Users/pjb/src/c/ensemble' cc -I. -MMD -c -o main.o main.c cc -I. -MMD -c -o ensemble.o ensemble.c cc -I. -MMD -c -o util.o util.c cc -I. -MMD -c -o list.o list.c bison -o ensemble_bison.c ensemble.bison cc -I. -MMD -c -o ensemble_bison.o ensemble_bison.c flex -o ensemble_flex.c ensemblpe.flex cc -I. -MMD -c -o ensemble_flex.o ensemble_flex.c cc -o ensemble main.o ensemble.o util.o list.o ensemble_bison.o ensemble_flex.o make[1]: Leaving directory '/Users/pjb/src/c/ensemble' # [pjb@despina :0.0 ensemble]$ cat *.d ensemble.o: ensemble.c ensemble.h list.h util.h ensemble_bison.o: ensemble_bison.c list.h util.h ensemble.h ensemble_flex.o: ensemble_flex.c util.h tokens.h list.o: list.c list.h util.h main.o: main.c ensemble.h list.h util.o: util.c util.h # [pjb@despina :0.0 ensemble]$ > Remember the other part of the problem is trying to build software on > Windows. If there is no Windows, there is no point. > > OK, I'll throw down this challenge: access the Tiny C/Github [actually > http://repo.or.cz/tinycc.git], and write me a batch file, to run in > the same directory as the supplied makefile, that will let me build > TCC for Windows, in a configurations that targets Windows (and say > x64). > > If makefiles are so ludicrously simple, it should be a piece of cake. Yep. >> You have so many choices: linux, freebsd, openbsd, darwin, illumos, etc. > > That's part of the problem. No, because in practice, you would just use linux. -- __Pascal J. Bourguignon http://www.informatimago.com