LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 02-13-2005, 08:46 AM   #1
darklogik_org
Member
 
Registered: Jan 2004
Distribution: freebsd 5.3, openbsd 3.6, slackware 10
Posts: 96

Rep: Reputation: 15
[bsdmake/pmake] Makefile Fun & Games


Probably an easy one for those in the know, but I've let myself get behind on Makefile theory...

Code:
# $Id: Makefile,v 1.2 2005/02/13 14:23:33 markzero Exp $

CC = cc
CFLAGS = -pipe -O -W -Wall -pedantic -ansi
RM = /bin/rm -f

all: SWp_API_logerr SWp_new SWp_tsuite_tools SWp_logerr

SWp_API_logerr:        $(.TARGET).c $(.TARGET).h
SWp_new:               $(.TARGET).c $(.TARGET).h $(.TARGET).r SWp_API_logerr
SWp_tsuite_tools:      $(.TARGET).c $(.TARGET).h
SWp_logerr:            $(.TARGET).c $(.TARGET).h 
SWp_example_object:    $(.TARGET).c $(.TARGET).h SWp_new

.c:
        $(CC) $(CFLAGS) -c $(.IMPSRC) -o $(.TARGET).o

clean:
        $(RM) *.o *.core
I want to add a new target - 'ExampleObjTest'. It's a single C source file that depends on SWP_new and SWp_example_object and should result in an executable.

What would be the tidiest and most concise way of adding ExampleObjTest given the implicit '.c' target?

Uh, perhaps not the best way to explain it.
 
Old 02-13-2005, 12:03 PM   #2
darklogik_org
Member
 
Registered: Jan 2004
Distribution: freebsd 5.3, openbsd 3.6, slackware 10
Posts: 96

Original Poster
Rep: Reputation: 15
I can't believe that something so simple is so utterly impossible. This is driving me to complete frustration.

I have the unit-test ExampleTestObj.c, it relies on SWp_new.o and SWp_example_obj.o to compile and link. SWp_new.o relies on SWp_API_logerr.o to link sucessfully. I should not have to specify every single dependency for every single target as the list will get longer and longer and there appears to be no other way to do this.
 
Old 02-13-2005, 01:34 PM   #3
darklogik_org
Member
 
Registered: Jan 2004
Distribution: freebsd 5.3, openbsd 3.6, slackware 10
Posts: 96

Original Poster
Rep: Reputation: 15
Took a different approach:

Code:
CC = cc
CFLAGS+= -O2 -pipe -W -Wall -pedantic -ansi
RM = /bin/rm -f
OBJS = SWp_API_logerr.o SWp_example_object.o SWp_logerr.o SWp_new.o \
       SWp_tsuite_tools.o
STATICLIB = libSWp.a
SHAREDLIB = libSWp.so
SHAREDFLAGS = -shared -Wl,-soname,libSWp.so

all: static shared

.c:
   ${CC} ${CFLAGS} -fpic -c ${.ALLSRC}

static: ${OBJS}
   ar rcv ${STATICLIB} ${OBJS}
   ranlib ${STATICLIB}

shared: ${OBJS}
   ${CC} ${SHAREDFLAGS} ${CFLAGS} ${OBJS} -o ${SHAREDLIB}

clean:
   ${RM} *.o *.core ${STATICLIB} ${SHAREDLIB}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fun Games for an old laptop. ned99 Linux - Games 4 10-14-2005 02:41 PM
most fun & excited things about Linux woranl Linux - General 2 07-27-2004 08:28 PM
Fun with strings & chars in C Scrag Programming 4 05-19-2004 03:03 PM
Fun with linux && Linus out and about. itsjustme General 5 03-24-2004 04:18 PM
VNC fun and games Nelleh Linux - Software 1 08-14-2002 11:26 PM


All times are GMT -5. The time now is 06:34 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration