makefile



  • Hallo Forum,

    ich komme nicht weiter mit meiner Makefile.

    CC := gcc            # Compiler
    WARNINGS		:= -Wall -Wpointer-arith -Wcast-align
    WARNINGS		+= -Waggregate-return -Wstrict-prototypes
    WARNINGS		+= -Wimplicit-function-declaration
    
    TARGE T:= udp-router #Programmname
    CXXFLAGS := $(WARNINGS) #Optimierungen 
    
    sources := src/global.c src/konfig.c src/route.c src/statistik.c 
    sources += src/udp-router.c src/utils.c src/version.c
    
    includes := include/all.h include/funktion.h include/global.h 
    includes += include/system.h /include/udprouter.h /include/typedef.h
    
    all : $(TARGET)
    
    $(TARGET):
    	$(CC) $(CXXFLAGS) -o $(TARGET) $(sources)
    
    clean :
    	rm -f $(SRC)/*.o
    

    Wie binde ich die include-dateien ein (includes)?

    mfg Oliver Kern.



  • daa531 schrieb:

    Wie binde ich die include-dateien ein (includes)?

    Wie, wo einbinden?

    Vielleicht meinst du so?:

    $(TARGET): $(includes)
        $(CC) $(CXXFLAGS) -o $(TARGET) $(sources)
    

    Aber ob das jetzt so das wahre ist..



  • nein das war nicht das ware HI.

    Das Project sieht folgendermassen aus:
    ../include/.h -> hier befinden sich alle include-dateien
    ../src/
    .c -> hier befinden sich alle sources-dateien
    ..makefile

    beim ausfuehren von makefile kommt folgende Fehlermeldung:
    /src/global.c:1: udp-router.h No such file or directory

    klar weil die inlcudes in der Makefile nicht definiert sind.
    Aber wie macht man das nun, hat jemand eine Loesung ?

    mfg Oliver kern.



  • Also liegt das Problem eher am Quelltext, als am Makefile..

    Entweder,
    dem gcc den Include-Pfad mitgeben. Mit -I glaub ich.

    oder,
    im c-file den relativen Pfad angeben. Also in dem Fall, #include "../includes/header.h".



  • Hallo Forum,

    die Makefile laeuft jetzt fast korrekt aber
    wenn ich Makefile ausfuehre werden die dateien mit der Endung *.o ins
    Hauptverzeichnis wo Makefile liegt abgelegt. Diese Dateien muessen aber
    in das /src Verzeichnis wo die Sources-Dateien liegen. Habe vieles
    probiert aber komme da micht weiter.

    srcdir = .
    
    WARNINGS		:= -Wall -Wpointer-arith -Wcast-align
    WARNINGS		+= -Waggregate-return -Wstrict-prototypes
    WARNINGS		+= -Wimplicit-function-declaration
    
    CC = gcc
    PROG = udp-router
    CCOPT = -O
    INCLS = -I. -I include
    DEFS =  -DHAVE_FCNTL_H=1 -DHAVE_MALLOC_H=1 -DHAVE_MEMORY_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_NET_SLIP_H=1 -DHAVE_VFPRINTF=1 -DHAVE_STRCASECMP=1 -DHAVE_ETHER_NTOA=1 -DHAVE_SETLINEBUF=1 -DRETSIGTYPE=void -DRETSIGVAL= -DHAVE_SIGSET=1  -DHAVE_FDDI
    
    # Standard CFLAGS
    CFLAGS = $(CCOPT) $(DEFS) $(INCLS) $(WARNINGS)
    
    LIBS = lib/libpcap.a
    
    INSTALL = /usr/bin/ginstall -c
    
    # Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
    # Also, gcc does not remove the .o before forking 'as', which can be a
    # problem if you don't own the file but can write to the directory.
    .c.o:
    	@rm -f $@
    	$(CC) $(CFLAGS) -c $(srcdir)/$*.c
    
    CSRC =	src/global.c src/konfig.c src/route.c src/statistik.c src/udp-router.c \
    	src/utils.c src/version.c
    
    SRC =	$(CSRC) $(GENSRC) $(LOCALSRC)
    
    # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
    # hack the extra indirection
    OBJ =	$(CSRC:.c=.o) 
    
    HDR =   include/all.h 
    include/global.h include/funktion.h include/system include/typedef.h
    
    CLEANFILES = $(PROG) $(OBJ)
    
    all: $(PROG)
    
    $(PROG): $(OBJ) ../libpcap-0.4a6/libpcap.a
    	@rm -f $@
    	$(CC) $(CFLAGS) -o $@ $(OBJ) $(LIBS)
    
    clean:
    	rm -f $(CLEANFILES)
    

    Hat jemand eine Loesung ?

    mfg Oliver kern.


Anmelden zum Antworten