Operating System - HP-UX
1752802 Members
5519 Online
108789 Solutions
New Discussion юеВ

Re: Making separate deployment

 
SOLVED
Go to solution
Vibhor Kumar Agarwal
Esteemed Contributor

Making separate deployment

Hello,

I have started using HP-UX just a week ago.
Prior i was working on Solaris.

To my extreme discomfort all my makefiles have stopped working here.
In solaris to prepare separate deployment I used:

-o $@ tag in build command to produce the output files.

I used to prefix path in .o like
/disk1/Deployement/A.o
/disk1/Deployement/B.o
etc,

Now my rule is
/disk1/Deployment/%.o:%.cpp
$(BUILD) $<
where $(BUILD) contains all compiler specific tags.

This used to work in solaris but here it gives error "Don't know how to make A.o" and subsequently all .o

Please help
Thanks in Advance
Vibhor Kumar Agarwal
6 REPLIES 6
Ermin Borovac
Honored Contributor

Re: Making separate deployment

Please try

.cpp.o:
$(BUILD) $<
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Making separate deployment

For this to work i have to remove the path prefix from the .o, otherwise it gives the same error. ( Don't know how to make )

On removing the prefix it creates the .o's in the same directory.
Vibhor Kumar Agarwal
Ermin Borovac
Honored Contributor

Re: Making separate deployment

Would the following makefile accomplish what you are after? It assumes sources and Makefile are in the current directory and objects go to /disk1/Deployment.

VPATH=/disk1/Deployment
OBJ=$(SRC:.c=.o)
all:
@$(MAKE) TARGET src="`echo *.c`"
TARGET: $(OBJ)
.c.o:
$(BUILD) $< -o $(VPATH)/$@
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Making separate deployment

Just a small confusion:

What does this line do
@$(MAKE) TARGET src="`echo *.c`"

As far as i have tried it makes the .o in the destination directory which i am able to achieve.
But during linking it can't find those .o's as its searching for them in the current directory.
How do i accomplish only this linking part.
Vibhor Kumar Agarwal
Ermin Borovac
Honored Contributor
Solution

Re: Making separate deployment

For linking part you can simply cd into /disk1/Deployment directory and run ld from there.

Line that does `echo *.c` is to get around the pattern matching problem. It defines variable SRC which holds a list of all source files. Variable OBJ holds list of all object files, obtained from SRC where .c is substituted with .o suffix.

Here is a full example

VPATH=/disk1/Deployment
OBJ=$(SRC:.c=.o)
all:
@$(MAKE) $(VPATH)/a.out src="`echo *.c`"
$(VPATH)/a.out: $(OBJ)
cd $(VPATH); ld -o a.out /usr/ccs/lib/crt0.o $(OBJ) -lc
.c.o:
cc -c $< -o $(VPATH)/$@

Vibhor Kumar Agarwal
Esteemed Contributor

Re: Making separate deployment

Bingo,

Thanks.

Gotcha.

All what i had to do was cd into the directory and then do linking.

One small confusion: my script was not working because i was using
%.o:%.cxx instead of .cxx.o

This % thing doesn't seem to work on HP-UX as its giving me an error
CC -0 -c ../source/file
Make: Cannot load CC. Stop.

But as soon as i replace
%.o:%.cxx with .cxx.o
everything works.

Since make isn't specific to any flavour of Unix then why is this thing happening?

Any comments.
Vibhor Kumar Agarwal