Thread: create dir in makefile

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    351

    create dir in makefile

    hi,

    i'm writing a makefile and i want to create directories in the install option.

    i've tried using mkdir to no avail.

    i read about using install() to do this but i cannot find any examples.
    any ideas?

    TIA, rotis23

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    mkdir to no avail? That seems a bit odd to me... what kind of errors is it giving you when you try using this? My first thought is to check your permissions to make sure that if you are creating directories in a root-owned directory, make sure you are running as root.

    But mkdir does work in makefiles, I promise (Well, in GNU make anyway).

    starX
    www.axisoftime.com

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    351
    sorry, i'll eat my hat!

    I rewrote this section and it seems to work now!

    i think it was a tab error - unexpected end of file etc

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    351
    hey starx,

    look at this makefile code:
    Code:
    install: myprog
    	@if [ -d $(INSTDIR) ]; \
    	then \
    		cp myprog $(INSTDIR);\
    		chmod a+x $(INSTDIR)/myprog;\
    		chmod og-w $(INSTDIR)/myprog;\
    		cp myprog.conf $(INSTDIR);\
    		mkdir $(INSTDIR)/DNS;\
    		mkdir $(INSTDIR)/ICMP;\
    		mkdir $(INSTDIR/SNMP;\
    		chown -R user1.user1 $(INSTDIR);\
    		echo "Installed in $(INSTDIR)";\
    	else \
    		echo "Sorry, $(INSTDIR) does not exist";\
    	fi
    if i only have two mkdirs, 'make install' works.

    if i add the third, as in this example, i get:

    syntax error: unexpected end of file

    i have tabs and not spaces!!!

    any ideas?

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    mkdir $(INSTDIR/SNMP;\
    shouldn't this be:

    Code:
    mkdir $(INSTDIR)/SNMP;\
    ?

    starX
    www.axisoftime.com

  6. #6
    Registered User
    Join Date
    Aug 2002
    Posts
    351
    yeah, obviously.....



    ...it was just a test.


    honestly!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile Problem: None rule to make target
    By chris24300 in forum Linux Programming
    Replies: 25
    Last Post: 06-17-2009, 09:45 AM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. How to create a file association program?
    By eShain in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2006, 12:15 PM
  4. Cannot create MDI Client Win
    By JaWiB in forum Windows Programming
    Replies: 1
    Last Post: 10-31-2005, 10:05 PM
  5. makefile woes
    By Grifftt in forum C Programming
    Replies: 2
    Last Post: 12-06-2002, 04:43 PM