# $Header: /CVSROOT/tinolib/old/Makefile.proto,v 1.17 2005/04/24 12:55:38 tino Exp $ # You have following: # - Linux # - tinolib in the subdirectory tino/ # - A source with a main() called !NAME!.c # (Usually !NAME! is `basename "$PWD"`) # Following will be extended and might change slightly. However I # want it to stay this simple, or even more simple! # To start from fresh, just do: # cp -i tino/*.dist tino/.*.dist . # rename .dist "" *.dist .*.dist # vi Makefile.tino # # Replace !NAME! with your program's name # make -f Makefile.tino # this will create the initial Makefile. # From now on the Makefile will update itself from Makefile.tino # (however sometimes you need to call make twice or thrice). # Note that the basic functions of the Makefile then can live # without the subdirectory tino/ # Some errors will show up, but everything still compiles. # What's the dark matter with all this here? # I want a hassle free method of keeping everything updated for me. I # want "make" to make it all, so no "./configure; make" I want to be # able to build everything without GNU extensions. This does not mean # to not use GNU extensions at all. However it shall be easy to # comment them out and still have a successful build. I want it easy. # Additionally a minimum of standard unix utilities shall be needed to # run this all. Note that I already think it needs too many of them. # However "make all" shall still do, I hope. # Prerequisites for "make all" in a distribution currently is: # 1) make (not neccessarily GNU make) # 2) awk (perhaps you need GNU awk, sorry) # 3) touch (could not circumvent this, sorry) # 4) An ANSI-C compiler, of course, which make knows about. # 5) The proper set of includes and libraries (possibly all GNU). # Nothing else (not even a bash, perl etc.) shall be needed, # and not a compiler with support for -M or -MM. # My long term goal for this here is (not joking): All you need is a # suitable ANSI-C compiler with libraries and such to compile my # distributions. For this there perhaps will be a little # Makefile.tino.run.c which can be compiled to a program which calls # the compiler for you (if you find a way to even get rid of the # compiler, I would be glad. Well, ok, that was a joke now *eg*). # However, to use all features of tinolib, you probably need a huge # Linux environment and some undefined and unclear setups (like CVS) # in place. But still it's the idea for the distribution to have an # easy "make all" process. And that the distribution can be # independent of tinolib if the sources do not depend on this library. # All portability issues shall be handled in tinolib in future, such # that you do not need a single #if in your source except for compile # time features. You get the idea. # That's why it is as it is. # $Log: Makefile.proto,v $ # Revision 1.17 2005/04/24 12:55:38 tino # started GAT support and filetool added # # Revision 1.16 2004/10/05 02:09:07 tino # A lot of design improvements around the make -f Makefile.tino # # Revision 1.15 2004/09/29 00:00:47 tino # make install and make dist, see Changelog # # Revision 1.14 2004/09/28 22:27:39 tino # added "make tar" in Makefile.proto # # Revision 1.13 2004/09/04 22:42:32 tino # "make it" target corrected, should not fail on top directory # # Revision 1.12 2004/09/04 22:22:59 tino # minor changes # # Revision 1.11 2004/09/04 14:25:20 tino # typos corrected # # Revision 1.10 2004/09/04 14:12:15 tino # Automated dependencies added and other make improvements. # # Revision 1.9 2004/08/24 23:50:11 tino # Quickstart (.dist) files added # # Revision 1.8 2004/08/22 05:47:34 Administrator # Now Makefile generator understands to look into variables set in Makefile. # This way Auto-Dependencies can be improved a little step and more important, # the "TINOCOPY" functionality was added, such that I can copy files from # elsewhere to the distribution and keep that files in sync. # # Revision 1.7 2004/08/15 21:51:19 Administrator # Bugfix: Rule for *_version.h file corrected. # # Revision 1.6 2004/08/15 21:46:28 Administrator # More Cygwin changes # # Revision 1.5 2004/07/28 03:44:26 tino # Makefile changes # # Revision 1.4 2004/07/28 03:42:19 tino # - # # Revision 1.3 2004/07/23 19:01:52 tino # CLEAN and DISTCLEAN defines for additional remove targets # # Revision 1.2 2004/07/21 13:37:39 tino # Little buglet added in case tinolib is not there as tino # # Revision 1.1 2004/07/21 13:29:14 tino # Creation of standard Makefile from Makefile.tino added # Expand PROGS into single names #C #C# Automatically generated from "PROGS" above #S PROGS #R PROG#c#=#v# # Override those if needed: STD_CFLAGS=-g -Wall -O3 STD_LDFLAGS= STD_LDLIBS= #C #C# From here no changes shall be needed. #C# (Except for the compiler generated dependencies at the end.) # Do not define those yourself! CFLAGS=$(DBG_FLAGS) $(ADD_CFLAGS) $(STD_CFLAGS) -I$(HERE) LDFLAGS=$(DBG_LDFLAGS) $(ADD_LDFLAGS) $(STD_LDFLAGS) LDLIBS=$(DBG_LDLIBS) $(ADD_LDLIBS) $(STD_LDLIBS) VERSIONFILE=$(PROG1)_version.h COMMON= \ $(VERSIONFILE) \ $(TINOINC) \ $(TINOLIB) \ #S TINOCOPY #R #p# \ AWK=awk TOUCH=touch # Following prorgrams shall not be needed in future! CP=cp STRIP=strip HERE=$(PWD) #C #C# Semi-automatically generated for CygWin (*.exe) PROGS_EXE= \ #S PROGS #R $(PROG#c#).exe \ ######################################################################## #C #C# Targets considered to work for all systems with GNU MAKE and GNU AWK all: $(PROGS) # The latter MAKE fails if there is no tinolib. This is normal! # We let Makefile depend on Makefile.md5, # so we can "redo" it if needed. # We "touch" it so that hopefully MAKE re-reads Makefile then. Makefile: Makefile.md5 $(TOUCH) Makefile # Makefile.md5 is a forced target to always execute it to check, # if Makefile must be redone. # I cannot make this depend on tino/ as you might not have this directory! # I don't want to depend this on a shell either, so I must use AWK! Makefile.md5:: @$(AWK) -vHERE="$(HERE)" -vMAKE="$(MAKE)" -vTINOCOPY="$(TINOCOPY)" 'BEGIN { \ if ((getline < "tino/Makefile")>0 && \ (getline < "tino/Makefile.proto")>0 && \ (getline < "tino/Makefile.awk")>-1) \ system(MAKE " -C tino tino HERE=\"" HERE "\" TINOCOPY=\"" TINOCOPY "\""); \ else if ((getline < "Makefile.md5")<0) \ printf "" >"Makefile.md5"; \ }' $(VERSIONFILE): VERSION Makefile $(AWK) -vPROG="$(PROG1)" '{ print "#define " toupper(PROG) "_VERSION \"" $$0 "\"" }' VERSION > $(VERSIONFILE) #C# Poor man's install install: IPATH="$(INSTALLPATH)"; [ -n "$$IPATH" ] || IPATH="$$HOME"; \ for a in $(PROGS); do $(RM) "$$IPATH/bin/$$a"; \ $(CP) "$$a" "$$IPATH/bin/$$a" && $(STRIP) "$$IPATH/bin/$$a"; done ######################################################################## #C #C# Special targets considered to work for all unix like systems #C# like CygWin # Makefile helping target, see tino/Makefile # In case you are in a subdirectory, # make this the first rule and let it cd up. it: all [ ".$(PWD)" != ".$(HERE)" ] || [ -f VERSION ] || \ { UP="`dirname "$(HERE)"`"; $(MAKE) -C"$$UP" it HERE="$$UP"; } clean: $(RM) *.o *.d *~ .*~ */*~ $(CLEAN) @$(MAKE) -C tino clean HERE="$(HERE)" distclean: clean $(RM) $(VERSIONFILE) $(PROGS) $(PROGS_EXE) $(DISTCLEAN) $(RM) Makefile.md5 core core.* @$(MAKE) -C tino distclean HERE="$(HERE)" ######################################################################## #C #C# Special targets in presence of tinolib #C# (subdirectory tino) dist: distclean $(MAKE) -C tino dist HERE="$(HERE)" DEBUGS="$(DBG_CFLAGS)$(DBG_LDFLAGS)$(DBG_LDLIBS)" tar: distclean $(MAKE) -C tino tar HERE="$(HERE)" diff: $(MAKE) -C tino diff HERE="$(HERE)" #C #C# automatically generated dependencies #S PROGS #R $(PROG#c#).o: $(PROG#c#).c $(COMMON) #R $(PROG#c#): $(PROG#c#).o $(OBJS) $(LIBS) #S TINOCOPY #R #p#: Makefile.md5 #R $(TOUCH) #p# #C #C# compiler generated dependencies, remove if incorrect #S PROGS #R #R# included: #v#.d #R$(PROG#c#).o:#include(#v#.d)