delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/11/29/14:39:14

Xref: news-dnh.mv.net comp.os.msdos.djgpp:3488
Path: news-dnh.mv.net!mv!barney.gvi.net!news.netrail.net!news.sprintlink.net!news.us.world.net!ns2.mainstreet.net!news.PBI.net!agis!usenet.eel.ufl.edu!newsfeed.internetmci.com!in2.uu.net!newsfeed.ACO.net!alijku06!news
From: Roland Exler <R DOT Exler AT jk DOT uni-linz DOT ac DOT at>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Q about djgpp and scanning dependencies with cpp
Date: 29 Nov 1995 09:47:39 GMT
Organization: Institute for el. Measurement, University of Linz, Austria
Lines: 85
References: <DIK58p DOT Hvw AT jade DOT mv DOT net>
Nntp-Posting-Host: sensor4.emt.uni-linz.ac.at
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

"Magnus Westroth" <Magnus DOT Westroth AT software DOT combitech DOT se> wrote:
>2) For an ongoing project I will probably use the GNUish make. I am thinking
>about using djgpp cpp for scanning my source code for dependencies and pipe 
>this info to a file which the makefile will include.
>   - Anyone have experience on this?

I use automatic dependency-generation for almost any programming with djgpp.
The following is a sample 'makefile', some remarks will follow

# begin 'makefile'
LIBSRC=demo1 demo2 demo3 demo4
DIVSRC=module1 module1
EXESRC=exe1 exe2

CXXFLAGS=-Wall -O2
TARGET_ARCH=-m486
LDLIBS= -L. -ldemo -lgpp -lpc -lm

%.d: %.cc
ifdef DEPEND
	$(CC) -MM $(CPPFLAGS) $< > $@
endif

%.exe: %
	strip $<
	coff2exe $<

exe: $(EXESRC:=.exe)

all: libdemo.a exe

libdemo.a: $(LIBSRC:=.o)
	ar -rs $@ $^
	ranlib $@

exe1: exe1.o

exe2: exe2.o module1.o module2.o

include $(LIBSRC:=.d)
include $(DIVSRC:=.d)
include $(EXESRC:=.d)

# clear Directory
clear:
	del *.o
	del *.d
#end 'makefile'

1) modules which should be combined into an library (libdemo.a) are listed in 
variable LIBSRC
2) modules which should give exe-files are listed in variable EXESRC
3) modules which should not go into an library but has to be linked are listed 
in variable DIVSRC
4) the compiler-flags are set using the var's the default rules of make uses
5) compilation for the dependencies is done conditional, so time could be saved 
by not recreating the dependencies any time something changes in an 
source-file. To (re)create the dependencies call 'make DEPEND=1'. I use -MM as 
I find it enough to scan only the headers included with "".
6) creating an .exe from the linked coff-type program needs the rule with 
strip/coff2exe
7) for any .exe to create there must exist one rule for 'linking', most times 
this would be of the form 'exe1: exe1.o' but other modules may be listed here.

WARNING:
If you've set '2r1' in your GO32 environment-variable and there exists an error 
in one of the header-files included you may get an invalid dependency-file (the 
error-message). This would cause make to fail until you delete this file as 
make includes it and thus generates invalid lines in the resulting makefile.

>   - Are there alternatives? (Our cross-compiler does not have cpp -M)
Why don't use the cpp from djgpp just for creation of the dependencies?

Hope this helps, 
  Roland

+---------------------------------------+---------------------------+
I Roland Exler                          I EMAIL:                    I
I Universitaet Linz                     I R DOT Exler AT jk DOT uni-linz DOT ac DOT at I
I Institut fuer Elektrische Messtechnik I                           I
I Altenbergerstr. 69                    I Phone:                    I
I A-4040 Linz, AUSTRIA                  I + 43 732 2468 9205        I
+---------------------------------------+---------------------------+


- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019