Issues with seperated .o directory and .. paths?

Emulation of old PCs, PC hardware, or PC peripherals.

Issues with seperated .o directory and .. paths?

Postby superfury » 2018-1-01 @ 01:33

I'm having the unipcemu directory within the repo store project-specific .c-files, while ../../projects_build(BUILD_DIR variable) contains the compiled(.o, .exe, .pbp etc.) files. This worked fine up till now, but I now have split part of the repo in a subrepository(../commonemuframework). Now the paths of the compiled object files for those object paths are positioned one directory up, causing problems.
I've tried replacing the paths before prepending the output directories with pathsubst using subst, but then Make suddenly complains that it has no rule to create the fixed output file? I simply replace ../ with subdir, while the object file compilation rule is simply:
Original(working):
Code: Select all
OBJS := $(patsubst %.o,$(BUILD_DIR)/$(BUILD_INTERMEDIATE)/%.o,$(OBJS))


New replacement:
Code: Select all
OBJS := $(patsubst %.o,$(BUILD_DIR)/$(BUILD_INTERMEDIATE)/%.o,$(subst ../,parentdir/,$(OBJS)))


Compiler rule for object files:
Code: Select all
$(BUILD_DIR)/$(BUILD_INTERMEDIATE)/%.o:%.c
   $(info Compiling $<)
   @$(MKDIR) -p $(dir $@)
   @${CC} $(OPTIMIZATIONFLAGS) ${CFLAGS} $(BUILD_CFLAGS) ${INCLUDE_DIRS} -c $< -o $@
   @${CC} $(CFLAGS) $(INCLUDE_DIRS) -c $< -MM -MF $(patsubst %.o,%.d,$@)
   @sed -i 's|$(notdir $@):|$@:|' $(patsubst %.o,%.d,$@)


New version(first line changed only):
Code: Select all
$(BUILD_DIR)/$(BUILD_INTERMEDIATE)/%.o:$(subst parentdir/,../,%.c)


But why isn't that rule firing like it should(neither new nor old rule when the OBJS path replacement new rule is applied(old one compiles in wrong parent directory(../../projects_build/$(BUILD_NAME) instead)?
Last edited by superfury on 2018-1-02 @ 03:26, edited 1 time in total.
superfury
l33t
 
Posts: 2103
Joined: 2014-3-08 @ 11:25
Location: Netherlands

Re: Issues with seperated .o directory and .. paths?

Postby superfury » 2018-1-01 @ 14:34

This is the unmodified Makefile for Windows(MinGW(64)):
https://bitbucket.org/superfury/unipcem ... ?at=master

Anyone can see what's going wrong with the path adjustments in my previous post?

Edit: Removing the part that replaces :%.c with : makes it compile somewhat, but shows some strange compilations of unfound .d.c source code files as well(which give errors compiling, which continues to the next files)?
Last edited by superfury on 2018-1-02 @ 03:27, edited 1 time in total.
superfury
l33t
 
Posts: 2103
Joined: 2014-3-08 @ 11:25
Location: Netherlands

Re: Issues with seperated .o directory and .. paths?

Postby superfury » 2018-1-01 @ 18:50

After fixing some stuff, it now compiles properly again(adding .d.o dummy ruke for those).
superfury
l33t
 
Posts: 2103
Joined: 2014-3-08 @ 11:25
Location: Netherlands


Return to PC Emulation

Who is online

Users browsing this forum: vladstamate and 3 guests