[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Makefile



On Tue, 1 Aug 2000 22:57:28 +0200,
sslug@sslug <sslug@sslug> wrote:

>Jeg er ny til Lotus Notes s=E5 b=E6r over med mig:
>GNU make har jeg imidlertid brugt siden '95:
>
>En mere-eller-mindre "beskidt" mulighed:
>(idet jeg foruds=E6tter at dependencies bliver *processed*  f=F8r commands =
>
>selv med parameteren -j)?:

Det gør de. Ellers ville man jo begynde at lave redundante programudførelser.

>#Makefile semi-sequential example
>#title is merly indicative
>
>.PHONY: default local=5Fglobal=5Fsub=5Fdependt=5Ftargets sub
>
>default: sub
>        make local=5Fglobal=5Fsub=5Fdependt=5Ftargets
>
>local=5Fglobal=5Fsub=5Fdependt=5Ftargets: $(local=5Fglobal=5Fdefault=5Ftarg=
>ets)
>
>sub:
>        [$(make=5Fsub=5Fad=5Flib=5Flisting)]
>
>#END  Makefile semi-sequential example
>
>For en god ordens skyld: Jeg har ikke afpr=F8vet ovenn=E6vnte eksempel

Det virker fint. Men der er et lille problem; hvis man skriver "make default"
går den i uendelig løkke. Det lyder måske ikke som et stort problem, men når
man har to targets der afhænger af "sub" og man ikke altid vil compile begge
targets er man lidt på spanden.

Jeg kommer lige med mit eksempel, hvis ovenstående ikke er klart. De to targets
er linux og dos.

CXXFLAGS= -O2 -Wall -g
DEPENDFLAGS = -M

DOSCXX = i386-pc-msdosdjgpp-c++
DOSAR = i386-pc-msdosdjgpp-ar
DOSCXXFLAGS = -O2 -Wall -Wno-uninitialized -msoft-float

DOSLIB= $(LIB:.a=dos.a)

OBJS = $(OBJSRC:.cpp=.o) 
EXEOBJS = $(EXESRC:.cpp=.o)
EXES = $(EXESRC:.cpp=)

DOSOBJS = $(OBJSRC:.cpp=.doso) 
DOSEXEOBJS = $(EXESRC:.cpp=.doso)
DOSEXES = $(EXESRC:.cpp=.exe)

ALLSRC = $(OBJSRC) $(EXESRC)
DEPENDS = $(ALLSRC:.cpp=.dep)

DOSDEPENDS = $(ALLSRC:.cpp=.dosdep)
.PHONY: clean linux veryclean dos $(SUBS) linux_ dos_

linux : $(SUBS)
	$(MAKE) linux_ $(MAKECMDGOALS)

linux_: $(LIB) $(EXES) $(DEPENDS) 

dos: $(SUBS)
	$(MAKE) dos_ $(MAKECMDGOALS)

dos_ : $(DOSLIB) $(DOSEXES) $(DOSDEPENDS) 

veryclean: clean $(SUBS)
	$(RM) $(EXES) $(LIB) $(DOSEXES) $(DOSLIB)

clean:
	$(RM) $(EXEOBJS) $(OBJS) $(DEPENDS) $(DOSEXEOBJS) $(DOSOBJS) $(DOSDEPENDS)

%.o: %.cpp 
	$(CXX) $(CXXFLAGS) $(COMPILE_FLAGS) -c $< -o $@

%.doso: %.cpp  
	$(DOSCXX) $(DOSCXXFLAGS) $(DOS_COMPILE_FLAGS) -c $< -o $@

$(LIB): $(OBJS)  
	ar r $@ $?

$(DOSLIB): $(DOSOBJS) 
	$(DOSAR) r $@ $?

$(EXES): % : %.o $(OBJS) $(LIBS)
	$(CXX) $(CXXFLAGS) $< $(OBJS) $(LINK_FLAGS) $(LIBS) -o $@

$(DOSEXES): %.exe : %.doso $(DOSOBJS) $(DOSLIBS)
	$(DOSCXX) $(DOSCXXFLAGS) $< $(DOSOBJS) $(DOSLIBS) $(DOS_LINK_FLAGS) -o $@
	upx -1 $@

$(DEPENDS): %.dep : %.cpp
	$(CXX) $(CXXFLAGS) $(DEPENDFLAGS) $(COMPILE_FLAGS) -c $< > $@

$(DOSDEPENDS): %.dosdep : %.cpp
	$(DOSCXX) $(DOSCXXFLAGS) $(DEPENDFLAGS) $(DOS_COMPILE_FLAGS) -c $< \
	| sed s/$*.o/$*.doso/ > $@

$(SUBS): 
	$(MAKE) -C $@ $(MAKECMDGOALS)
	
include $(DEPENDS)
include $(DOSDEPENDS)


-- 
Anders Bo Rasmussen          mailto:sslug@sslug
Frimestervej 42 1.tv         http://www.image.dk/~abr
2400 Kbh. NV
Denmark


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *