makefile aus Eclipse CDT abändern



  • Guten Tag,
    Ich möchte gerne das automatisch generierte makefile aus Eclipse CDT
    abändern. Durch CDT wird ein makefile, objects.mk, subdir.mk und ein
    objects.mk File generiert. Ich möchte alles in ein einziges File:
    makefile packen. Auch wird durch CDT ein Ordner angelegt und die
    Referenzen der *.c und *.h ist auf dem übergeordneten Ordner. Ich
    möchte, dass das makefile aus dem gleichen Ordner wo die Source
    Dateien sind ausführen können.
    Also, das CDT makefile sieht folgendermassen aus:

    ########################################################################### ##### 
    # Automatically-generated file. Do not edit! 
    ########################################################################### ##### 
    -include ../makefile.init 
    RM := rm -rf 
    # All of the sources participating in the build are defined here 
    -include sources.mk 
    -include subdir.mk 
    -include objects.mk 
    ifneq ($(MAKECMDGOALS),clean) 
    ifneq ($(strip $(C_DEPS)),) 
    -include $(C_DEPS) 
    endif 
    endif 
    -include ../makefile.defs 
    # Add inputs and outputs from these tool invocations to the build 
    variables 
    # All Target 
    all: bachelor 
    # Tool invocations 
    bachelor: $(OBJS) $(USER_OBJS) 
            @echo 'Building target: $@' 
            @echo 'Invoking: MacOS X C Linker' 
            gcc -L/opt/local/lib -lNetpbm -o "bachelor" $(OBJS) $(USER_OBJS) $ 
    (LIBS) 
            @echo 'Finished building target: $@' 
            @echo ' ' 
    # Other Targets 
    clean: 
            -$(RM) $(OBJS)$(EXECUTABLES)$(C_DEPS) bachelor 
            -@echo ' ' 
    .PHONY: all clean dependents 
    .SECONDARY: 
    -include ../makefile.targets
    

    ----------------------
    Das subdir.mk File enthält:

    ########################################################################### ##### 
    # Automatically-generated file. Do not edit! 
    ########################################################################### ##### 
    # Add inputs and outputs from these tool invocations to the build 
    variables 
    C_SRCS += \ 
    ../canny.c \ 
    ../starter.c \ 
    ../tracing.c 
    OBJS += \ 
    ./canny.o \ 
    ./starter.o \ 
    ./tracing.o 
    C_DEPS += \ 
    ./canny.d \ 
    ./starter.d \ 
    ./tracing.d 
    # Each subdirectory must supply rules for building sources it 
    contributes 
    %.o: ../%.c 
            @echo 'Building file: $<' 
            @echo 'Invoking: GCC C Compiler' 
            gcc -I/opt/local/include -O3 -c -fmessage-length=0 -MMD -MP -MF"$(@: 
    %.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" 
            @echo 'Finished building: $<' 
            @echo ' '
    

    -------------------
    Die anderen beiden Files, objects.mk und sources.mk enthalten keine
    Zuweisungen.
    Ich konnte alles soweit abändern, dass ich nur noch ein makefile habe,
    das sieht dann folgendermassen aus:

    ########################################################################### ##### 
    # Automatically-generated file. Do not edit! 
    ########################################################################### ##### 
    -include ../makefile.init 
    RM := rm -rf 
    # All of the sources participating in the build are defined here 
    # Add inputs and outputs from these tool invocations to the build 
    variables 
    C_SRCS += \ 
    ../canny.c \ 
    ../starter.c \ 
    ../tracing.c 
    OBJS += \ 
    ./canny.o \ 
    ./starter.o \ 
    ./tracing.o 
    C_DEPS += \ 
    ./canny.d \ 
    ./starter.d \ 
    ./tracing.d 
    # Each subdirectory must supply rules for building sources it 
    contributes 
    %.o: ../%.c 
            @echo 'Building file: $<' 
            @echo 'Invoking: GCC C Compiler' 
            gcc -I/opt/local/include -O3 -c -fmessage-length=0 -MMD -MP -MF"$(@: 
    %.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" 
            @echo 'Finished building: $<' 
            @echo ' ' 
    ifneq ($(MAKECMDGOALS),clean) 
    ifneq ($(strip $(C_DEPS)),) 
    -include $(C_DEPS) 
    endif 
    endif 
    -include ../makefile.defs 
    # Add inputs and outputs from these tool invocations to the build 
    variables 
    # All Target 
    all: cannyandtracing 
    # Tool invocations 
    cannyandtracing: $(OBJS) $(USER_OBJS) 
            @echo 'Building target: $@' 
            @echo 'Invoking: MacOS X C Linker' 
            gcc -L/opt/local/lib -lNetpbm -o "cannyandtracing" $(OBJS) $ 
    (USER_OBJS) $(LIBS) 
            @echo 'Finished building target: $@' 
            @echo ' ' 
    # Other Targets 
    clean: 
            -$(RM) $(OBJS)$(EXECUTABLES)$(C_DEPS) cannyandtracing 
            -@echo ' ' 
    .PHONY: all clean dependents 
    .SECONDARY: 
    -include ../makefile.targets
    

    ---------------------
    Das kompilieren klappt soweit gut. Allerdings nur wenn sich das
    makefile in einem Ordner 'unter' den Resourcen befindet. Wie klappt
    es, dass ich ein make im gleichen Ordner ausführen kann?
    Ich ging davon aus die Source Referenzen wie ../canny.c \ müssen auf ./
    canny.c abgeändert werden. Dies funktioniert allerdings nicht.
    Bin dankbar für jede Hilfe.



  • Hallo,

    Wenn ich Dich richtig verstanden habe, dann geht das folgendermaßen:

    Du gehst auf: File->Properties->C/C++ build
    Klickst das: Generate Makefiles automatically weg
    Trägst Deine gweünschte Directory ein und Thats It.

    Gruß
    Tentone



  • Wenn ich das richtig sehe wird auf diesem Weg aber kein makefile generiert.

    Was ich brauche ist ein makefile, dass jenes von CDT ersetzt. Es soll im gleichen Ordner laufen wo die source Dateien sind.

    Da ich mich mit makefiles nicht auskenne, hab ich einfach angefangen, jenes von CDT so abzuänder, dass es für mich stimmen könnte.

    Aber evtl. kann das makefile auch viel einfacher und von Hand erstellt werden.
    Wie gesagt, kenn ich mich mit makefiles allerdings nur schlecht aus.



  • hat sich nun erledigt:

    RM := rm -rf
    
    # Add inputs and outputs from these tool invocations to the build variables 
    C_SRCS = \
    ./canny.c \
    ./starter.c \
    ./tracing.c 
    
    OBJS = \
    ./canny.o \
    ./starter.o \
    ./tracing.o 
    
    C_DEPS = \
    ./canny.d \
    ./starter.d \
    ./tracing.d 
    
    # Each subdirectory must supply rules for building sources it contributes
    %.o: %.c
    	gcc -I/opt/local/include -O3 -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
    
    ifneq ($(MAKECMDGOALS),clean)
    ifneq ($(strip $(C_DEPS)),)
    -include $(C_DEPS)
    endif
    endif
    
    # All Target
    all: cannyandtracing
    
    # Tool invocations
    cannyandtracing: $(OBJS) 
    	@echo 'Building target: $@'
    	gcc -L/opt/local/lib -lNetpbm -o "cannyandtracing" $(OBJS) 
    	@echo 'Finished building target: $@'
    	-@echo ' '
    
    # Other Targets
    clean:
    	-$(RM) $(OBJS)$(EXECUTABLES)$(C_DEPS) cannyandtracing
    	-@echo ' '
    

Anmelden zum Antworten